package com.jojo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

@Data
@AllArgsConstructor
public class Result<T> implements Serializable {
    private Integer code;

    private String msg;

    private T data;

    public Result() {

    }

    public static Result<Object> build(Integer code, String msg) {
        Result<Object> result = new Result<Object>();
        result.setCode(code);
        result.setMsg(msg);
        result.setData("");
        return  result;
    }

    public static<T> Result<T> success(String msg, T data) {
        Result<T> result = new Result<T>();
        result.setCode(200);
        result.setMsg(msg);
        result.setData(data);
        return  result;
    }

    public static<T> Result<T> success( T data) {
        Result<T> result = new Result<T>();
        result.setCode(200);
        result.setMsg("操作成功");
        result.setData(data);
        return  result;
    }
}
